--[[/**
-- * 
 * 添加时触发
 * 寻找场上攻击最高的敌人,给他添加个buff
-- *
-- */]]

---@class BuffEffect615100 : BaseBuffEffect
BuffEffect615100 = ClientFight.CreateClass("BuffEffect615100", ClientFight.BaseBuffEffect)
local t = BuffEffect615100

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
 local source = buff.source;

 local buffEffectValue = buff.buffBean.f_BuffEffectValue;

 local list = fight.teams[3 - source.teamIndex].fighters;
 local attMax = nil;
 for k, fighter  in pairs( list) do
 if (fighter:isDie() or fighter:isSummons()) then
 goto continue;
 end
 if (attMax == nil) then
 attMax = fighter;
  goto continue;
 end
 local att = FighterAttributeManager.getFightAttr(fighter, FighterAttributeEnum.ATK);
 local maxAtt = FighterAttributeManager.getFightAttr(attMax, FighterAttributeEnum.ATK);
 if (att > maxAtt) then
 attMax = fighter;
 end
  ::continue::
 end
 if (attMax == nil) then
 return IBuffEffect.REMOVE;
 end
 local log = attMax;
 SkillRoleMgr.savePathFile(  "[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff"
 .. buff.modelId .. " 西泽被动触发,寻找场上攻击最高的敌方英雄 "..log.fighterId.." ,给他添加个buff : " ..buffEffectValue[1]);
 for k, buffId  in pairs( buffEffectValue) do
 BuffManager.addBuff(fight, buff.skill, buff.source, attMax, false, buffId, 1);
 end
 return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()